package com.gxa.zhonglong.service.impl;

import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.GoodsGoldMapper;
import com.gxa.zhonglong.pojo.GoodsGold;
import com.gxa.zhonglong.service.GoodsGoldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/11/01 12:54
 * Description:
 * Version: V1.0
 */
@Service
public class GoodsGoldServiceImpl implements GoodsGoldService {
    @Autowired
    private GoodsGoldMapper goodsGoldMapper;

    @Override
    public List<Map<String, Object>> selectAll() {
        return goodsGoldMapper.selectAll();
    }

    @Override
    public void add(GoodsGold goodsGold) throws BusinessException {
        if (!goodsGoldMapper.add(goodsGold)){
            throw new BusinessException(ExceptionCode.ADD_DEFEATED);
        }
    }

    @Override
    public void update(GoodsGold goodsGold) throws BusinessException {
        if (!goodsGoldMapper.update(goodsGold)){
            throw new BusinessException(ExceptionCode.UPDATE_FALSE);
        }
    }

    @Override
    public void del(List<Long> ids) throws BusinessException {
        if (!goodsGoldMapper.del(ids)){
            throw new BusinessException(ExceptionCode.DELETE_FALSE);
        }
    }
}
